First line of message marked with empty <A> tag?

Hi,

Hoping this is the right place to ask. We have a program that can open a .msg file by using the CreateItemFromTemplate() function, and then retrieve the text as html using the HTMLBody property.

Now if you open the msg file in Outlook it looks fine (and looks as though it is just plain text). But in the html returned by the HTMLBody property the first line of text always gets surrounded by an <A> tag and looks like this:

<P><A NAME=""><FONT SIZE=1 FACE="Times New Roman">Hi person</FONT></A>

This is odd, and causing an issue as this <A> tag is obviously getting interpreted as you would expect by our text viewer control and displayed as a hyperlink.

What is going on? And is there a way to stop it?

(Obviously could parse out <A> tags with an empty name or that have no href attribute, but would still like to identify what's going on here and if possible find a solution or option in Outlook that can prevent this and thereby avoid/delay requiring a software patch!)

February 26th, 2015 10:26am

Hello,

You can use the Body property which returns a plain text.

Be aware, Outlook uses Word as an email editor. So you can use the WordEditor property of the Inspector class to get an instance of the Document class which represents the message body. All possible ways of working with item bodies are described in the Chapter 17: Working with Item Bodies .

All supported and unsupported HTML elements, attributes, and cascading style sheets properties are described in the following series of articles in MSDN:

Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007 (Part 1 of 2)

Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007 (Part 2 of 2)

Free Windows Admin Tool Kit Click here and download it now
February 26th, 2015 12:15pm

Useful information, but not what I'm looking for as I will ultimately need the text from the message in html format.

Although I guess it might possibly help to avoid the problem if there is a way in Outlook to ask what the original format of the message is (e.g. plaintext or html), so that I could get either the Body text and convert it to html myself or the HTMLBody text depending on this format...

I would still like to know why Outlook appears to be applying this formatting rather randomly to the returned text. Is it a bug?

(Should also point out this is Outlook 2010).
  • Edited by RJP1973 Thursday, February 26, 2015 1:12 PM Forgot to state Outlook version
February 26th, 2015 1:03pm

It looks like there is a bug in your text control because the <a name=""> is a valid HTML element. The name attribute specifies the name of an anchor and is used to create a bookmark inside a document.

See HTML name Attribute for more information.

Free Windows Admin Tool Kit Click here and download it now
February 26th, 2015 1:15pm

I know its a valid tag. But the point is that shouldn't be there!

The original text when viewed in Outlook does not display this first line as a hyperlink. As far as I can tell there is nothing special about this first line in the original email. It is not a hyperlink. It is not supposed to be a hyperlink.

And yet when I access the message via automation using the above mechanism, Outlook is returning the text with that <A> tag around the first line, essentially turning it into a hyperlink.

Edit: More information!

Strangely, I can't reproduce this issue with any arbitrary email msg file on my test system, but I can reproduce it with msg files dragged back from the customer site having the issue. So...its something vary specific in an msg file, whereupon the email looks fine when opened directly in Outlook, but makes the first line into a hyperlink when accessed via Outlook automation and the HTMLBody property

  • Edited by RJP1973 Friday, February 27, 2015 10:42 AM
February 26th, 2015 2:01pm

A link suggesting this is indeed some kind of strange Outlook 2010 bug?

http://answers.microsoft.com/en-us/office/forum/office_2010-outlook/outlook-2010-underlines-first-line-of-mail-reply/a9e3a36f-bd48-4988-bcea-0c3594640cca

Free Windows Admin Tool Kit Click here and download it now
March 4th, 2015 11:54am

Crazy, this just happened to me today. Agree with above that this makes my business emails seem unprofessional.

Here is what outlook 2010 is adding to my replies (not just the first reply either, multiple replies in same conversation):

<a href="" rel="nofollow" shape="rect" name="_MailEndCompose">

TIA to Microsoft or whoever can solve or debug this one.

March 5th, 2015 2:28pm

Ok, so a bit more information.

I recently acquired Outlook Spy and poked inside this MSG file. And found that in the PR_RTF_COMPRESSED property (which seems to be how the full-formatted text is stored) that the first line of the rtf is actually marked as a bookmark!

Its this bookmark that is presumably getting translated into an empty <A> tag when we ask Outlook for the HTMLBody.

So, now the question is, what in Outlook or Exchange Server can put such a bookmark into the text??

Free Windows Admin Tool Kit Click here and download it now
March 23rd, 2015 8:03am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics